<?php
namespace app\admin\controller;

class VisitLog extends Base{
    //
    protected function initialize() {
        parent::initialize();
        $this->model = 'VisitLog';
    }
    //
    protected function _before_index(){
        $thead = [
            'vlid' => 'VLID',
            'tname' => '二级目录',
            'ip' => '访问IP',
            'city' => 'IP归属地',
            'block' => '屏蔽地区',
            'tpl' => '显示模板',
            'types' => '屏蔽类型',
            'addtime' =>'访问时间',
            'isp' => '网络类型',
            'agent' => '客户终端',
            //'referer' => '来源',
            //'url' => 'URI',
        ];
        $this->assign('thead', $thead);
    }
    //
    protected function _filter($map){
        return $map;
    }
    //
    protected function _after_list($list){
        $typesArr = ['0'=>'未设置','1'=>'强制屏蔽','2'=>'电脑端屏蔽','3'=>'终端关键字','4'=>'客户端屏蔽','5'=>'网络类型屏蔽','6'=>'地区屏蔽','7'=>'附加屏蔽','8'=>'IP黑名单','9'=>'禁止访问'];
        foreach($list as $key => $row){
            $list[$key]['types'] = $typesArr[$row['types']] ?? '';
            $list[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
        }
        return $list;
    }
    //
    protected function _filter_del(){
        return [];
    }
    //
    protected function _after_del($rows){
        $logs = [];
        foreach($rows as $row){
            $logs[] = ['pk' => 'vlid', 'value' => $row['vlid'], 'row' => $row];
        }
        $this->logAll($logs);
    }
}